package com.zili.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author : ranzlupup
 * @date : 2023/3/7 16:28
 */
public class SourceFunctionCustom {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        // 有了自定义的 SourceFunction，调用 addSource 方法
        //  SourceFunction 接口定义的数据源，并行度只能设置为 1，如果数据源设置为大于 1 的并行度，则会抛出异常
        DataStreamSource<Event> eventDataStreamSource = env.addSource(new ClickSource());


        eventDataStreamSource.print("SourceCustom");
        env.execute();
    }
}
